<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="zh-cn">
    <head>
        <!-- Bootstrap -->
        <include file="Include/css" />
        <title></title>
        <link href="__STATICS__/css/admin/index.css" rel="stylesheet">
        <link href="__STATICS__/css/sweet-alert.css" rel="stylesheet">
        <script type="text/javascript" src="__STATICS__/js/sweet-alert.min.js"></script>
    </head>

    <body>
        <include file="Include/nav_top" />
        <div class="container clearfix" id="left_menu_wraper" >
            <include  file="Include/menu_left" />
            <div id="right-content">
                <div id="right-content-inner">
                    <ul class="breadcrumb">
                        <span>您的位置：</span>
                        <li><a href="{:U('Houtai/Index/index')}">首页</a> </li>
                        <li class="">商家管理</li>
                        <li class="">商家列表</li>
                        <li class="active">商品列表</li>
                    </ul>
                    <div class="back pull-right clearfix">
		                   <!-- <a class="btn btn-default" href="{:U('CNEPAdmin/Shop/shopList')}?shopType={$Think.request.shopType}">
		                        <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> 后退
		                    </a>  -->
		                     <a class="btn btn-default" href="javascript:history.back();">
		                        <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> 后退
		                    </a>            
		                </div>
                    <p>
                    
                    </p>
                    <div role="tabpanel">
                        <div class="row clearfix margin10 form-horizontal">
                            <form  name="query" >
                                <span class="pull-left ml30 form_bar">查询：</span>
                                <div class="col-md-2">
                                    <input type="text" name="sGoodsSn" value="{$Think.request.sGoodsSn}" placeholder=" 商品编号" class="pull-left ml10 form-control" />
                                    <input type="hidden" name="sShopID" value="{$Think.request.sShopID}" />
                                </div>
                                <div class="col-md-2">
                                    <input type="text" name="sGoodsName" value="{$Think.request.sGoodsName}" placeholder=" 商品名称" class="pull-left ml10 form-control" />
                                </div>
                                <div class="col-md-2">
                                    <select  name="sCatID" class="pull-left ml10 form-control" >
                                            <option value="-1" <eq name="Think.request.sCatID" value="-1" > selected </eq> >-分类-</option>
                                            <volist name="catList" id="ct">
                                                 <option value="{$ct.catID}" <eq name="Think.request.sCatID" value="$ct['catID']" > selected </eq> >{$ct.catName}</option>
                                            </volist>
                                    </select>
                                </div>
                                <div class="col-md-2">
                                    <select  name="sIsSale" class="pull-left ml10 form-control" >
                                            <option value="-1" <eq name="Think.request.sIsSale" value="-1" > selected </eq> >-状态-</option>
                                            <option value="0" <eq name="Think.request.sIsSale" value="0" > selected </eq> >下架</option>
                                            <option value="1" <eq name="Think.request.sIsSale" value="1" > selected </eq> >上架</option>
                                    </select>
                                </div>
                                <!-- <div class="col-md-2">
                                    <select  name="sCommentType" class="pull-left ml10 form-control" >
                                            <option value="-1" <eq name="Think.request.sCommentType" value="-1" > selected </eq> >-类型-</option>
                                            <option value="1" <eq name="Think.request.sCommentType" value="1" > selected </eq> >附属商品</option>
                                            <option value="0" <eq name="Think.request.sCommentType" value="0" > selected </eq> >增值商品</option>
                                    </select>
                                </div> -->
                                <button type="submit" class="pull-left btn btn-default ml20">
                                    搜索
                                </button>
                            </form>
                        </div>
                                <table class="table ">
                                    <thead class="table_head">
                                        <tr class="border">
                                            <th>编号</th>
                                            <th>图片</th>
                                            <th>商品名称</th>
                                            <th>商品ID</th>
                                            <th>顺序</th>
                                            <th>总库存</th>
                                            <th>默认单价</th>
                                            <th>实际单价</th>
                                            <th>是否上架</th>
                                            <th>添加时间</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <volist name="list" id="vo">
                                            <tr class="qr_tar">
                                                <td>
                                                    {$vo.goodsSn}
                                                </td>
                                                <td>
                                                    <img src="{$imgDomain}{$vo.thumb}" width="60px" height="60px" > 
                                                </td>
                                                <td>{$vo.goodsName}</td>
                                                <td>{$vo.goodsID}</td>
                                                <td>{$vo.ind}</td>
                                                <td>{$vo.num}</td>
                                                <td>{$vo.marketPrice}</td>
                                                <td>{$vo.goodsPrice}</td>
                                                <td data-id="{$vo.goodsID}" >
		                                                <switch name="vo.isSale">
		                                                <case value="1" ><font color="green" >上架</font> / <a href="javascript:void(0)" class="is_sale" data-val="0" >下架</a></case>
		                                                <case value="0"><a href="javascript:void(0)" class="is_sale"  data-val="1" >上架</a> / <font color="red" >下架</font>  </case>
		                                            	</switch>
												</td>
                                                <td>{$vo['addTime'] | date="Y/m/d H:i:s",###} </td>
                                                <td data-id="{$vo.goodsID}" >
                                                    <a href="{:U('CNEPAdmin/Goods/goodsMsg',array('goodsID'=>$vo['goodsID']))}?shopID={$Think.request.sShopID}&sGoodsSn={$Think.request.sGoodsSn}&sGoodsName={$Think.request.sGoodsName}&sCatID={$Think.request.sCatID}&sIsSale={$Think.request.sIsSale}&p={$Think.request.p}"
                                                       class="edit_look" >编辑</a> /
                                                    <a href="javascript:void(0);" class="tar_delete" >删除</a>
                                                </td>
                                            </tr>
                                        </volist>
                                    </tbody>
                                </table>

                                <div class="clearfix s_page pull-right">
                                    {$page}
                                </div>
                            </div>

                    </div>

                </div>

            </div>
        
        <include file="Include/script" />
        <script src="__STATICS__/js/bootstrap-editable.min.js"></script>

       <script>
            var isReload = false; // 标识弹出框关闭之后是否刷新页面
            var myDom; // 当前操作的dom对象
            var img_url="__STATICS__/images";
            
            /*菜单展开及高亮*/
            $(function () {
                $('.shop').addClass('open');
                //$('#goods4').addClass('active');
                
                //改变评论状态
                $(".is_sale").on("click",function(e) {
                    var curDom = $(this);
                    var goodsID = $(this).closest("td").attr("data-id");
                    var status = $(this).attr("data-val");
                    
                     var jsonData = {};
                     jsonData.goodsID = goodsID;
                     jsonData.isSale = status;
                    ajax_go_1(jsonData,"{:U('CNEPAdmin/Goods/updateGoodsStatus')}",onIsSale);
                });
                
                function onIsSale(rsp) {
                    if(rsp.result > 0) {
                        swal("操作成功！","","success");
                        window.location.reload();
                        
                    } else{
                        swal("无更新","","error");
                    }
                }
                
                
                /*删除弹窗*/
                $(".tar_delete").on("click", function () {
                    var self = $(this);
                    swal({   title: "您确定吗?",
                                text: "您将删除此商品！",
                                type: "warning",
                                showCancelButton: true,
                                confirmButtonColor: "#DD6B55",
                                confirmButtonText: "是的，删除",
                                cancelButtonText: "放弃",
                                closeOnConfirm: false
                            },
                            function (isConfirm) {
                                if (isConfirm) {
                                    var ajaxData = {};
                                    ajaxData.goodsID = self.closest('td').attr('data-id');
                                    ajax_go_1(ajaxData ,"{:U('CNEPAdmin/Goods/deleteGoods')}", onDel);
                                }

                            });
                });
                
                function onDel(rsp) {
                    if(rsp.result > 0) {
                        window.location.reload();
                    } else {
                        swal("操作失败",'',"error");
                    }
                }
                          

            });
                        
        </script>
    </body>
</html>